From 639932ad8a93157628937d03c2da72edfd853bf8 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 20 Apr 2021 17:24:13 +0100 Subject: [PATCH] a11y: Emit window:activate event Orca uses the window:activate event type to track top levels, and avoid being spammed by events coming from non-focused windows. --- gtk/a11y/gtkatspicontext.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c index c15c4d37b9..9f69b53181 100644 --- a/gtk/a11y/gtkatspicontext.c +++ b/gtk/a11y/gtkatspicontext.c @@ -882,6 +882,22 @@ emit_focus (GtkAtSpiContext *self, NULL); } +static void +emit_window_activate (GtkAtSpiContext *self) +{ + if (self->connection == NULL) + return; + + g_dbus_connection_emit_signal (self->connection, + NULL, + self->context_path, + "org.a11y.atspi.Event.Window", + "activate", + g_variant_new ("(siiva{sv})", + "", 0, 0, g_variant_new_string("0"), NULL), + NULL); +} + static void gtk_at_spi_context_state_change (GtkATContext *ctx, GtkAccessibleStateChange changed_states, @@ -1117,6 +1133,9 @@ gtk_at_spi_context_platform_change (GtkATContext *ctx, gboolean state = gtk_accessible_get_platform_state (GTK_ACCESSIBLE (widget), GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE); emit_state_changed (self, "active", state); + + if (gtk_accessible_get_accessible_role (accessible) == GTK_ACCESSIBLE_ROLE_WINDOW && state) + emit_window_activate (self); } } -- 2.30.2